#@layout()

#define script()
<script>

    function doDel(id) {
        if (confirm("确定要删除该流程吗？删除后不可恢复")){
            ajaxGet("#(CPATH)/admin/flow/doDelTemplate/" + id);
        }
    }

</script>
#end

#define content()
    <section class="content-header">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-6">

                    <div class="row mb-2">
                        <div class="col-sm-12">
                            <h1>
                                流程管理
                                <small data-toggle="tooltip" title="" data-placement="right"
                                       data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                                <small> 首页 / 审核 / 流程管理</small>
                            </h1>
                        </div>
                    </div>
                </div>

                <div class="col-sm-6 ">
                    <div class=" float-sm-right" style="padding-top: 15px">
                        <a href="template/edit" class="btn btn-primary ">
                            <i class="fas fa-plus"></i> 新建流程
                        </a>
                    </div>
                </div>

            </div>

        </div><!-- /.container-fluid -->
    </section>


    <section class="content">

        <div class="container-fluid">
                <div class="card card-outline card-primary">
                    <div class="card-header with-border">
                        <form class="admin-search-panel" action="" method="get">
                            <input type="hidden" name="status" value="">
                            <div class="row">

                                <div class="form-group col-lg-2">
                                    <input type="text" placeholder="流程名称" class="form-control" name="title" value="#para('title')">
                                </div>

                                <div class="form-group col-lg-2">
                                    <select class="form-control" name="deployed">
                                        <option value="">发布状态</option>
                                        <option value="true" #selectedIf(para('deployed') == 'true')>已发布</option>
                                        <option value="false" #selectedIf(para('deployed') == 'false')>未发布</option>
                                    </select>
                                </div>


                                <div class="form-group col-lg-2">
                                    <button type="submit" class="btn btn-primary ">查询</button>
                                    <button type="reset" class="btn btn-default">重置</button>
                                </div>

                            </div>
                            <!-- /.card-body -->
                        </form>

                    </div>
                    <!-- /.card-header -->
                    <div class="card-body p-0">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 10px">
                                    <input class="tableCheckAll" id="checkall" type="checkbox"/>
                                </th>
                                <th style="width: 30%">流程名称</th>
                                <th>描述</th>
                            </tr>
                            #for(flowTemplate : page.list)
                            <tr>
                                <td><input name="tableItem" type="checkbox" value="#(flowTemplate.id)" />
                                </td>
                                <td>
                                    <strong>
                                        <a href="#(CPATH)/admin/flow/template/edit/#(flowTemplate.id)">
                                            #(flowTemplate.title ??)
                                            （#(flowTemplate.deployed? '已发布' : '未发布')）
                                        </a>
                                    </strong>
                                    <div class="jp-action-card">
                                        <div class="jp-action-body">
                                            <a href="#(CPATH)/admin/flow/template/edit/#(flowTemplate.id)">编辑</a> |
                                            <a href="#(CPATH)/admin/flow/template/design/#(flowTemplate.id)">流程设计</a> |
                                            #if(!flowTemplate.deployed)
                                            <a open-type="ajax" data-ok-function="refresh" href="#(CPATH)/admin/flow/doDeployTemplate/#(flowTemplate.id)">发布</a> |
                                            <a href="javascript:;" class="red-action"  onclick="doDel('#(flowTemplate.id)')">删除</a>
                                            #else
                                            <a open-type="confirm" data-title="确定要下线该流程吗？" data-text="下线将会删除其所有任务。"
                                               class="red-action" data-ok-function="refresh" href="#(CPATH)/admin/flow/doUnDeployTemplate/#(flowTemplate.id)">下线</a>
                                            #end

                                        </div>
                                    </div>
                                </td>
                                <td>#(flowTemplate.description ??)</td>
                            </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.card-body -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-6">
                            </div>

                            <div class="col-sm-6">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                    <!-- /.card-footer -->
                </div>
                <!-- /.card -->
            </div>
    </section>
#end
